﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Elysium.Demo;
using SIIE_ERP.Codigo;
using System.IO;

namespace Elysium.Demo.Configuracion
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class CargaDatos_Cliente1 : UserControl
    {
        private UsuarioActivo _sesion;

        public CargaDatos_Cliente1(ref UsuarioActivo usuario)
        {
            InitializeComponent();
            this._sesion = usuario;  
        }

        private void ButtonExcel_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog();
            fbd.Description = "Elija la carpeta donde desea guardar la plantilla";
            System.Windows.Forms.DialogResult result = fbd.ShowDialog();

            string fName = "Plantilla_Clientes.xlsx";

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    File.Copy(System.IO.Path.Combine(Directory.GetCurrentDirectory() + "\\_ArchivosParaBin\\", fName), System.IO.Path.Combine(fbd.SelectedPath + "\\", fName), true);
                    MessageBox.Show("Plantilla descargada correctamente");
                }
                catch (Exception)
                {
                    MessageBox.Show("La ruta elegida no está disponible.");
                    return;
                }
            }
            else
            {
                MessageBox.Show("Se canceló la Selección.");
            }
        }

        private void ButtonInformacion_Click_1(object sender, RoutedEventArgs e)
        {
            WindowAyuda Ayuda = new Elysium.Demo.WindowAyuda("CargaDatos.htm", "Ayuda");
            Ayuda.Owner = SIIE_ERP.View.NavegacionUI.GetParentWindow(this); Ayuda.ShowDialog();
        }

        private void ButtonRegresar_Click_1(object sender, RoutedEventArgs e)
        {
            ((ScrollViewer)this.Parent).Content = new CargaDatos_Main(ref _sesion);
        }

        private void Button_Guardar_Click(object sender, RoutedEventArgs e)
        {
            ((ScrollViewer)this.Parent).Content = new CargaDatos_Cliente2(ref _sesion);
        }
    }
}
